/**
 * @Version 1.0.1
 * @Author DemoHui
 * @Date 2022/09/30
 */
import Vue from "vue";
import VueRouter from "vue-router";
import Login from "@/views/login/index";
import Layout from "@/views/layout";

Vue.use(VueRouter);

const routes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: (resolve) => require(["@/views/redirect"], resolve),
      },
    ],
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/dataShow", // 大屏
    name: "DataShow",
    component: (resolve) => require(["@/views/bigScreen/index"], resolve),
  },
  {
    path: "",
    component: Layout,
    redirect: "index",
    children: [
      {
        path: "index",
        component: (resolve) => require(["@/views/home"], resolve),
        name: "首页",
        meta: { title: "首页", icon: "dashboard", affix: true },
      },
      {
        path: "/requestTest",
        name: "RequestTest",
        component: (resolve) => require(["@/views/requestTest"], resolve),
      },
      {
        path: "/mkAnalysis",
        name: "mkAnalysis",
        component: (resolve) => require(["@/views/mkAnalysis"], resolve),
      },
      {
        path: "/codeEdit",
        name: "codeEdit",
        component: (resolve) => require(["@/views/codeEdit"], resolve),
      },
      {
        path: "/webSsh",
        name: "webSsh",
        component: (resolve) => require(["@/views/webSsh"], resolve),
      },
      {
        path: "/organization",
        name: "organization",
        component: (resolve) => require(["@/views/organization"], resolve),
      },
    ],
  },
  // {
  //   path: "/about",
  //   name: "About",
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () =>
  //     import(/* webpackChunkName: "about" */ "../views/About.vue"),
  // },
];

// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch((err) => err);
};

const router = new VueRouter({
  routes,
});

export default router;
